import moment from "moment";
import { serveURL } from "./request";
import { userInfoAPI } from "../server/auth";
export const dalImg = (url) => {
  if (url) {
    if (url.startsWith("http")) {
      return url;
    }
    return serveURL + url;
  }
  return "https://img2.baidu.com/it/u=2142150771,4031198976&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500";
};

export const isCheckedToday = async () => {
  const today = moment().format("YYYY-MM-DD");
  const userName = await (await userInfoAPI()).data.userName;
  const localDate = localStorage.getItem("check-" + userName);
  if (localDate) {
    if (localDate == today) {
      return true;
    }
    localStorage.setItem("check-" + userName, today);
    return false;
  } else {
    localStorage.setItem("check-" + userName, today);
    return false;
  }
};
